package com.myCommunity.ui;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.myCommunity.dao.impl.ForumDaoImpl;
import com.myCommunity.dao.impl.TopicDaoImpl;
import com.myCommunity.entity.Forum;
import com.myCommunity.entity.Topic;
import com.myCommunity.entity.Users;

public class IndexServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		List<Forum> f = new ForumDaoImpl().getForumLevel(); 
		request.setAttribute("forum", f);
		int pageNum = 1;
		int pageSize = 6;
		List<Topic> topicList = new TopicDaoImpl().getTopicList(pageNum, pageSize);
		request.setAttribute("topic",topicList);
	
		Users user = (Users) request.getSession().getAttribute("user");

		request.setAttribute("user", user);
		
		request.getRequestDispatcher("index.jsp").forward(request, response);
	}

		public static void main(String[] args) {
			int pageNum = 1;
			int pageSize = 6;
			List<Topic> topicList = new TopicDaoImpl().getTopicList(1, 6);
				for(Topic t : topicList)
					System.out.println(t.getTitle());
		}
}
